import {
    getFactoryMoldingList as getMesMaterialStationModelingList,
    getModelingLevel
} from '@/api/materialStation/mesMaterialStationModel'

export const mesMaterialStationModelingDialog = {
    data () {
        return {
            mesMaterialStationModelingDialogVisible: false, //表格弹框隐藏显示
            getMesMaterialStationModelingList, // 获取弹框数据接口
            hasMesMaterialStationModelingFooter: true, // 是否需要底部按钮默认true
            mesMaterialStationModelingSearchDialog: {
                inline: true,
                formDesc: {
                    modelingCode: {
                        type: "input",
                        layout: 8,
                        label: $i18n.t('mesMaterialStationModel.modelCode'),
                    },
                    modelingName: {
                        type: "input",
                        layout: 8,
                        label: $i18n.t('mesMaterialStationModel.modelName'),
                    },
                }
            },
            mesMaterialStationModelingDialogColumn: [
                {
                    prop: "modelingCode",
                    label: $i18n.t("mesMaterialStationModel.modelingCode"),
                    align:'left',
                    minWidth: 150,
                    showOverflowTooltip: true
                },
                {
                    prop: "modelingName",
                    label:$i18n.t("mesMaterialStationModel.modelingName"),
                    minWidth: 250,
                    showOverflowTooltip: true
                },
                {
                    prop: "level",
                    label:$i18n.t("mesMaterialStationModel.level"),
                    minWidth: 100,
                    showOverflowTooltip: true,
                    optionProp: {
                        value: "value",
                        label: "description",
                    },
                    option: async (data) => {
                        const list = await getModelingLevel()
                        return list.data.result
                    }
                }
            ]
        }
    },
    methods: {
        // 弹框表格，双击表格，或者点击确定 返回选中数据
        getSelectMesMaterialStationModeling(data) { 
            // 调试完成记得删除控制台打印
            console.log("选中数据", data);
            if(!!data&&data.length>0){
                let row=data[0];
                if(row.level=="4"||row.level=="5"||row.level=="6"){
                    // 这里可以自定义返回字段信息 
                    // 第一个入参为当前表单绑定的对象，第二个入参为要修改的字段名，第三个入参为选中数据中相应信息
                    this.$set(this.formDataDialog, "farmName", data[0].modelingName);
                    this.$set(this.formDataDialog, "farmCode", data[0].modelingCode);
                }else{
                    this.$message.warning($i18n.t("mesMaterialStationModel.selectModelingLimit"));
                }
            }
            return false;
        },
    }
}